﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pulse
{
    class Cell
    {
        /* The tile IDs to draw at the ground level */
        public List<int> baseTiles = new List<int>();

        /* The block tile IDs to draw that appear to be taller in the pseudo-3D space. */
        public List<int> heightTiles = new List<int>();

        /* The extra "cover" of tile IDs to draw on top of pre-existing tiles */
        public List<int> layerTiles = new List<int>();

        public bool Walkable = true;

        public int tileID
        {
            get { return baseTiles.Count > 0 ? baseTiles[0] : 0; }
            set
            {
                if (baseTiles.Count > 0)
                    baseTiles[0] = value;
                else
                    AddBaseTile(value);
            }
        }

        public Cell(int ID)
        {
            tileID = ID;
        }

        public int Height
        {
            get { return heightTiles.Count; }
        }

        public void AddBaseTile(int ID)
        {
            baseTiles.Add(ID);
        }

        public void AddHeightTile(int tileID)
        {
            heightTiles.Add(tileID);
        }

        public void AddLayerTile(int tileID)
        {
            layerTiles.Add(tileID);
        }

        public void RemoveBaseTile(int ID)
        {
            baseTiles.Remove(ID);
        }

        public void RemoveHeightTile(int tileID)
        {
            heightTiles.Remove(tileID);
        }

        public void RemoveLayerTile(int tileID)
        {
            layerTiles.Remove(tileID);
        }

        public void RemoveTile()
        {
            if (heightTiles.Count > 0)
                heightTiles.RemoveAt(0);
            else if (layerTiles.Count > 0)
                layerTiles.RemoveAt(0);
            else if (baseTiles.Count > 1)
                baseTiles.RemoveAt(1);
        }

    }
}
